package client;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;

public class Screen_Login extends JPanel {
	private JLabel lblWelcomeCustomer;
	private JLabel lblLoginId;
	private JLabel lblPassword;
	private JButton btnLogin;
	private JTextField tfLoginId;
	private JPasswordField pfPassword;

	/**
	 * Create the panel.
	 */
	public Screen_Login() {
		setBackground(UIManager.getColor("Label.background"));
		setLayout(null);
		setSize(320, 480);

		lblWelcomeCustomer = new JLabel("Welcome!");
		lblWelcomeCustomer.setOpaque(true);
		lblWelcomeCustomer
				.setBackground(UIManager.getColor("Label.background"));
		lblWelcomeCustomer.setHorizontalAlignment(SwingConstants.CENTER);
		lblWelcomeCustomer.setForeground(Color.BLACK);
		lblWelcomeCustomer.setFont(new Font("Eurostile", Font.BOLD, 16));
		lblWelcomeCustomer.setBounds(0, 35, 320, 50);
		add(lblWelcomeCustomer);

		tfLoginId = new JTextField();
		tfLoginId.setBounds(60, 124, 200, 35);
		tfLoginId.setFont(new Font("Eurostile", Font.PLAIN, 12));
		add(tfLoginId);
		tfLoginId.setColumns(10);

		pfPassword = new JPasswordField();
		pfPassword.setBounds(60, 194, 200, 35);
		pfPassword.setFont(new Font("Eurostile", Font.PLAIN, 12));
		add(pfPassword);
		pfPassword.setColumns(10);

		lblLoginId = new JLabel("Username");
		lblLoginId.setOpaque(true);
		lblLoginId.setBackground(UIManager.getColor("Label.background"));
		lblLoginId.setHorizontalAlignment(SwingConstants.LEFT);
		lblLoginId.setForeground(Color.BLACK);
		lblLoginId.setFont(new Font("Eurostile", Font.PLAIN, 12));
		lblLoginId.setBounds(63, 100, 150, 20);
		add(lblLoginId);

		lblPassword = new JLabel("Password");
		lblPassword.setOpaque(true);
		lblPassword.setBackground(UIManager.getColor("Label.background"));
		lblPassword.setHorizontalAlignment(SwingConstants.LEFT);
		lblPassword.setForeground(Color.BLACK);
		lblPassword.setFont(new Font("Eurostile", Font.PLAIN, 12));
		lblPassword.setBounds(63, 170, 150, 20);
		add(lblPassword);

		btnLogin = new JButton("Login");
		btnLogin.setFont(new Font("Eurostile", Font.BOLD, 14));
		btnLogin.setBounds(60, 300, 200, 45);
		add(btnLogin);

	}

	public JButton getBtnLogin() {
		return btnLogin;
	}

	public String getTfLoginId() {

		return tfLoginId.getText();

	}

	public String getPfPassword() {

		return pfPassword.getText();

	}

	/**
	 * Clear the fields
	 */
	public void clearFields() {
		pfPassword.setText("");
		tfLoginId.setText("");
	}

	/**
	 * Add ActionListener to JButtons and JTextField
	 * 
	 * @param ActionListener
	 *            l
	 */
	public void addActionListener(ActionListener l) {

		btnLogin.addActionListener(l);
		pfPassword.addActionListener(l);
		tfLoginId.addActionListener(l);
	}
}